package cn.com.joyplus.wechat.listener;

import cn.com.joyplus.wechat.exceptions.WechatEventListenerException;
import cn.com.joyplus.wechat.model.WechatEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * Created by 王灏川(wangrs@qq.com) on 2017/8/11 0011.
 *
 * 处理用户关注公众号事件
 * <xml><ToUserName><![CDATA[gh_baaf1686e313]]></ToUserName>
 *  <FromUserName><![CDATA[obWde08iJXKTezCCnERt39XphoAI]]></FromUserName>
 *  <CreateTime>1501971054</CreateTime>
 *  <MsgType><![CDATA[event]]></MsgType>
 *  <Event><![CDATA[subscribe]]></Event>
 *  <EventKey><![CDATA[]]></EventKey>
 *  </xml>
 */
@Component
public class EventSubscribeListener implements IMsgListener {
    private static final Logger logger = LoggerFactory.getLogger(EventSubscribeListener.class);

    @Autowired
    TextMessageListener textMessageListener;

    @Override
    public String process(WechatEvent event)  throws WechatEventListenerException {
        return textMessageListener.buildMsg(event.getFromUserName(),"你好！欢迎加入我们!");
    }
}
